package com.admin.action;

import com.admin.service.AdminService;
import com.admin.service.AdminServiceImpl;
import com.admin.service.ServiceAdmin;
import com.uni.entity.User;
import com.uni.service.Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author Uni
 * @create 2021/12/2 22:32
 */
@WebServlet(name = "DeleteEmpAction", urlPatterns = "/adminDeleteUser")
public class DeleteUserAction extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer id = Integer.parseInt(req.getParameter("id"));
        try{
            Service.user.deleteUserById(id);
        } catch (Exception e){
            e.printStackTrace();
            resp.getWriter().write("false");
        }
        resp.getWriter().write("true");
    }
}
